package day01;

import java.io.*;

/**
 * @author ZJX
 * @version 1.0
 * @descption  输入以数字为主（如矩阵、多组整数）
 * @since 2025/10/14 20:55
 */
public class Nums {
    public static void main(String[] args) throws IOException {
        // 数字输入专用：StreamTokenizer 解析数字效率极高
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(System.out);

        // 循环处理多组测试用例（直到 EOF）
        while (in.nextToken() != StreamTokenizer.TT_EOF) {
            int n = (int) in.nval; // 读第一个数字
            in.nextToken();
            int m = (int) in.nval; // 读第二个数字

            // 读 n * m 矩阵
            int[][] mat = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    in.nextToken();
                    mat[i][j] = (int) in.nval;
                }
            }

            // 算法逻辑：例如输出矩阵元素和
            int sum = 0;
            for (int[] row : mat) {
                for (int num : row) sum += num;
            }
            out.println(sum);
        }

        out.close(); // 关闭时自动刷新
    }
}

